package com.example.dormitorymanagement.config;

import org.springframework.http.HttpHeaders;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.PrintWriter;


public class logon implements HandlerInterceptor
{

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

//        HttpSession session = request.getSession();
//
//        Object username = session.getAttribute("username");
//
//        if ("OPTIONS".equals(request.getMethod()))
//        {
//            return true;
//        }
//
//        if ( session.getAttribute("username") == null )
//        {
//            response.setCharacterEncoding("utf-8");
//
//            response.setContentType("text/html;charset=utf-8");
//
//            PrintWriter writer = response.getWriter();
//
//            writer.print("请登录");
//
//            return false;
//        }

        return true;

    }
}
